using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text;

namespace Pbdms.PDFMaker
{
    /// <summary>
    /// this class provides services to create a pdf document 
    /// and write a string into the file as a paragraph
    /// </summary>
    public class StringWriter
    {
        /// <summary>
        /// create a pdf document and write a string into the file as a paragraph
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="str"></param>
        public static void getPDFDocument(String filePath, String str)
        {
            Document doc = new Document();
            try
            {
                //create a pdf file
                PdfWriter.GetInstance(doc, new System.IO.FileStream(filePath, System.IO.FileMode.Create));
                doc.Open();                
                Paragraph pr = new Paragraph(str, new Font(iTextSharp.text.Font.HELVETICA, 13, iTextSharp.text.Font.NORMAL, Color.BLACK));
                doc.Add(pr);
            }
            catch
            {
                Common.Global.showMsgOneButton("Unsuccessful in writing pdf file, an unexpected error has occur, please try again", 'C');
            }
            finally
            {
                doc.Close();
            }
        }
    }
}
